package edu.wisc.hevea.constants;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class ApplicationConstants {
    public static Set<String> AVAILABILITY_ZONES;
    public static String VIRGINIA_DC = "VIRGINIA_DC";
    public static String IAD_DC = "IAD_DC";
    public static String DUBLIN_DC = "DUBLIN_DC";
    public static String HONGKONG_DC = "HONGKONG_DC";
    
    public static Map<String,String> HOST_DC_MAPPING;
    
    public static Map<String,String> ZOOKEEPER_DC_MAPPING;
    
    public static String ELECTION_PREFIX = "ELECTION";
    public static String ALL_BROKERS = "ALL_BROKERS";
    public static String ALIVE_BROKERS = "ALIVE_BROKERS";
    
	public static final Short HIGH_WATER_MARK = 20;
	public static final Short LOW_WATER_MARK = 10;

    
    static {
    	
    	AVAILABILITY_ZONES = new HashSet<String>();
    	AVAILABILITY_ZONES.add(VIRGINIA_DC);
    	AVAILABILITY_ZONES.add(IAD_DC);
    	AVAILABILITY_ZONES.add(DUBLIN_DC);
    	AVAILABILITY_ZONES.add(HONGKONG_DC);    
    	
    	ZOOKEEPER_DC_MAPPING = new HashMap<String,String>();
    	
    	ZOOKEEPER_DC_MAPPING.put("127.0.0.1:2181", VIRGINIA_DC);
    	ZOOKEEPER_DC_MAPPING.put("127.0.0.1:2182", IAD_DC);
    	ZOOKEEPER_DC_MAPPING.put("127.0.0.1:2183", DUBLIN_DC);
    	
    	
    	HOST_DC_MAPPING = new HashMap<String,String>();
    	HOST_DC_MAPPING.put("127.0.0.1:10000", VIRGINIA_DC);
    	HOST_DC_MAPPING.put("127.0.0.1:10001", VIRGINIA_DC);
    	
    	HOST_DC_MAPPING.put("127.0.0.1:20000", IAD_DC);
    	HOST_DC_MAPPING.put("127.0.0.1:20001", IAD_DC);
    	
    	HOST_DC_MAPPING.put("127.0.0.1:30000", DUBLIN_DC);
    	HOST_DC_MAPPING.put("127.0.0.1:30001", DUBLIN_DC);
    	
    	HOST_DC_MAPPING.put("127.0.0.1:40000", HONGKONG_DC);
    	HOST_DC_MAPPING.put("127.0.0.1:40001", HONGKONG_DC);
    	
		for (int i = 2; i < 10; i++) {
			HOST_DC_MAPPING.put(String.format("127.0.0.1:1000%d", i),
					VIRGINIA_DC);
			HOST_DC_MAPPING.put(String.format("127.0.0.1:2000%d", i), IAD_DC);
			HOST_DC_MAPPING
					.put(String.format("127.0.0.1:3000%d", i), DUBLIN_DC);
			HOST_DC_MAPPING.put(String.format("127.0.0.1:4000%d", i),
					HONGKONG_DC);
		}
		
		for (int i = 10; i < 100; i++) {
			HOST_DC_MAPPING.put(String.format("127.0.0.1:100%d", i),
					VIRGINIA_DC);
			HOST_DC_MAPPING.put(String.format("127.0.0.1:200%d", i), IAD_DC);
			HOST_DC_MAPPING
					.put(String.format("127.0.0.1:300%d", i), DUBLIN_DC);
			HOST_DC_MAPPING.put(String.format("127.0.0.1:400%d", i),
					HONGKONG_DC);
		}
    	
    }
    
    /*
     
       VDC
 127.0.0.1 10000
 127.0.0.1 10001
 
 IAD
 127.0.0.1 20000
 127.0.0.1 20001
 
 DUB
 127.0.0.1 30000
 127.0.0.1 30001
 
 HKG
 127.0.0.1 40000
 127.0.0.1 40001
      
     */
}
